home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 1 / CU Amiga Magazine CD-ROM Special Edition (1995)(EMAP Images)(GB)[Issue 1995-11].iso / Aminet / comm / tcp / AmiTCPsesn1_1.lha / AmiTCP_session-1.1 / c / purge.rexx < prev   
OS/2 REXX Batch file  |  1995-06-16  |  1KB  |  59 lines

  1. /*
  2.  * purge version 1.0
  3.  *
  4.  * ARexx script to delete old news articles.
  5.  * Usage: purge.rexx <active file> <days>
  6.  *
  7.  * Written by David Jameson (dave@freeside.thegap.com), 1994.
  8.  */
  9.  
  10. arg active_filename number_days
  11.  
  12. /* Open RexxSupport library */
  13.  
  14. if ~show('L', 'rexxsupport.library') then do
  15.     if addlib('rexxsupport.library', 0, -30, 0) then
  16.         say 'added rexxsupport.library'
  17.     else do
  18.         say 'failed to open rexxsupport.library'
  19.         exit 10
  20.     end
  21. end
  22.  
  23. /* Calcaulate date before which articles will be deleted */
  24. days = date('I')
  25. days = days - number_days
  26. newdate = date('E', days, 'I')
  27. newdate = translate(newdate, '-', '/')
  28.  
  29. if ~open('active_file', active_filename, 'R') then do
  30.     say "Can't open active file" active_filename
  31.     exit 10
  32. end
  33.  
  34. address command
  35. 'resident c:delete'    /* for speed */
  36.  
  37. do until eof('active_file')
  38.     /* Read next line of active file */
  39.     nextline = readln('active_file')
  40.     parse var nextline newsgroup hi lo status
  41.  
  42.     if newsgroup ~= "" then do
  43.     say 'Purging articles from newsgroup ' newsgroup '...'
  44.  
  45.     /* Convert newsgroup name into directory name */
  46.     directory = 'uunews:'||translate(newsgroup, '/', '.')
  47.  
  48.     /* Delete articles with creation date on or before 'newdate' */
  49.     if directory ~= 'uunews:' then do
  50.         'list ' directory 'files upto ' newdate  ,
  51.             ' lformat "delete %p%n" to t:purge_articles'
  52.         'execute t:purge_articles'
  53.         'delete >nil: t:purge_articles'
  54.     end
  55.     end
  56.  
  57.     say ""
  58. end
  59.